import numpy as np

data1 = [1, 2, 3, 4, 5]
np1 = np.array(data1)
print(np1)
# 一维数组切片
np11 = np1[2:4]  # 1 2 3 4 5  左闭右开
print(np11)
#   多维数组切片
data2 = [6, 7, 8, 9, 10]
data3 = [11, 12, 13, 14, 15]
data4 = [16, 17, 18, 19, 20]
data5 = [21, 22, 23, 24, 25]
data6 = [26, 27, 28, 29, 30]
np2 = np.array([[data1, data2, data3], [data4, data5, data6]])

print(np2[0:1,0:1])

#列切片  降维到一维后  进行切片操作
print(np2[:,:,0:2])


#数组堆叠
#垂直堆叠   多维数组

stacked_vertically = np.vstack((data1, data2))
print(stacked_vertically)

#水平堆叠    水平扩充
stacked_horizontally = np.hstack((data1, data2))
print(stacked_horizontally)



# # 保存数组到文件
# np.save('my_array.npy', np1)
#
# # 加载数组
#
# loaded_data = np.load('my_array.npy')



